package eg.backend.repository.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import eg.backend.base.repository.EntityRepositoryImpl;
import eg.backend.domain.User;
import eg.backend.repository.UserRepository;

public class UserRepositoryImpl extends EntityRepositoryImpl<User, String> implements UserRepository {
	@Override
	public User get(String identifier) {
		return this.baseDao.get(identifier, User.class);
	}
	
	public User findByEmail(String email) {
		String queryName = "User.getByEmail";
		Map<String, Object> queryParams = new HashMap<String, Object>();
		queryParams.put("email", email);
		return this.getByNamedQuery(queryName, queryParams);
	}

	public List<User> findByName(String name) {
		String queryName = "User.findByName";
		Map<String, Object> queryParams = new HashMap<String, Object>();
		queryParams.put("name", name);
		return this.findByNamedQuery(queryName, queryParams);
	}

}
